import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

// HJ85 最长回文子串
 public class HJ85 {

     public static void main(String[] args) {
         Scanner sc = new Scanner(System.in);
         while (sc.hasNext()) {
             String str = sc.nextLine();
             int count = 0;
             for (int i = 0; i < str.length(); i++) {
                 char c = str.charAt(i);
                 int j = str.indexOf(c, i+1);
                 while(j != -1){
                     String s = str.substring(i, j + 1);
                     if (s.length() % 2 == 0) {
                         String s1 = s.substring(0, s.length() / 2);
                         String s2 = s.substring(s.length() / 2);
                         s2 = new StringBuilder(s2).reverse().toString();
                         if (s1.equals(s2) && count < s.length()) {
                             count = s.length();
                             System.out.println(s);
                         }
                     }else if(s.length() % 2 == 1 ){
                         String s1 = s.substring(0, s.length() / 2);
                         String s2 = s.substring(s.length() / 2 + 1);
                         s2 = new StringBuilder(s2).reverse().toString();
                         if (s1.equals(s2) && count < s.length()) {
                             count = s.length();
                             System.out.println(s);
                         }
                     }
                     j = str.indexOf(c, j+1);
                 }
             }
             System.out.println(count);
         }
     }
 }

